$('#submit').click(function(){

	var currentPassword = $.trim($('#currentPassword').val());

	var password = $.trim($('#password').val());

	var repassword = $.trim($('#repassword').val());

	if(!currentPassword || !password || !repassword){
		$("body").append($.errorAlert('此信息必填，请重新输入'));

	    // $.clearAlert();

	    return; 
	}

	if(password != repassword){
		$("body").append($.errorAlert('两次输入的密码不匹配，请重新输入'));

	    // $.clearAlert();

	    return; 
	}
	var rel = /^(?=.*[a-z])[a-z0-9]+/ig;

	if(password.length < 6 || !rel.test(password)){
		$("body").append($.errorAlert('请输入6-16位字符，由字母、数字和组成'));

	    // $.clearAlert();

	    return; 
	}

	$.post("/repassword",
			{'currentPassword':currentPassword, 'password':password, 'repassword':repassword},
			function(result){
	            if(result.status == true){
	              
	                $("body").append($.successAlert(result.msg+" 3秒后自动跳转"));

					setTimeout(function (){window.location.href='/setting'}, 3000)
	            }else{
	            	$("body").append($.errorAlert(result.msg));

	            	// $.clearAlert();
	            	
					// btn.button('reset')

					return false;	
	            }
	},"json");

})

$('input').click(function(){
	$('.errorAlert').remove();
})